#include "gofgame/common/resource/TextureBrushResource.h"
#include <cocos2d.h>

using namespace gofgame::common::resource;
using namespace std;

TextureBrushResource::TextureBrushResource(const char *imageName, Brush *baseBrush) {
	this->imageName = imageName;
	if (!baseBrush) {
		baseBrush = Brush::white();
	}
	this->baseBrush = baseBrush;
}

void TextureBrushResource::onCollectFileNames(FileNameCollector &fnc) {
	fnc.collect(this->imageName);
}

void TextureBrushResource::onLoad() {
	Ref<CCTexture2D> tex = CCTextureCache::sharedTextureCache()->addImage(this->imageName.c_str());
	this->value.initialize(new TextureBrush(tex, this->baseBrush));
}
